package com.itwill.ecom.boardType;

import java.util.HashMap;
import java.util.List;

//예외처리.
public class BoardTypeService {
	private BoardTypeDao boardTypeDao;
	
	public BoardTypeService(){
		System.out.println("### BoardTypeService()");
	}
	
	public BoardTypeService(BoardTypeDao boardTypeDao){
		System.out.println("### BoardTypeService(BoardTypeDao boardTypeDao)");
		this.boardTypeDao = boardTypeDao;
	}
	
	public void setBoardTypeDao(BoardTypeDao boardTypeDao){
		System.out.println("### BoardService : setBoardTypeDao(BoardTypeDao boardTypeDao)");
		this.boardTypeDao = boardTypeDao;
	}
	private BoardTypeDao getBoardTypedDao(){
		System.out.println("### BoardTypeService : getBoardTypedDao()");
		return this.boardTypeDao;
	}
	
	public int create(BoardTypeBeans boardTypeBeans){
		int result = -1;
		
		try{
			result = getBoardTypedDao().create(boardTypeBeans);
			result=1;
		}
		catch(Exception e){			
			System.out.println(e.getMessage());
		}		
		return result;
	}
	
	public List<BoardTypeBeans> getAllBoardType(){
		List<BoardTypeBeans> resultList = null;
		try{
			resultList = getBoardTypedDao().selectAllList();
		}catch(Exception e){			
			System.out.println(e.getMessage());
		}
		return resultList;
	}
	
	public int updateBoardType(BoardTypeBeans boardTypebeans){
		int result = -1;
		try{
			result=getBoardTypedDao().update(boardTypebeans);
			result=1;
		}catch (Exception e){
			System.out.println(e.getMessage());
		}
		return result;
	}
	
	public int deleteBoardType(int board_no){
		int result = -1;
		
		try{
			result = getBoardTypedDao().delete(board_no);
			result = 1;
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return result;
	}

	public BoardTypeBeans getBoardType(int boardtype_no){
		BoardTypeBeans boardTypeBeans = null;
		
		try{
			boardTypeBeans = getBoardTypedDao().getBoardTypeBeans(boardtype_no);
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return boardTypeBeans;
	}
}
